package com.jsgt.greekfire.ui.trading.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.fhx.core.base.BaseAdapter
import com.fhx.core.base.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.CoinBean

class PriceAdapter(private val isUp: Boolean) : BaseAdapter<CoinBean>() {

    override fun provideViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder? {
        val view =
            LayoutInflater.from(parent.context).inflate(R.layout.item_coin_price_num, parent, false)
        return VH(view)
    }

    inner class VH(itemView: View) : BaseViewHolder(itemView) {
        var price_tv: TextView? = null
        var num_tv: TextView? = null

        init {
            price_tv = itemView.findViewById(R.id.price_tv)
            num_tv = itemView.findViewById(R.id.num_tv)
        }

        fun bindData(bean: CoinBean) {
            if (isUp) {
                price_tv?.setTextColor(itemView.resources.getColor(R.color.red_DE6C65))
            } else {
                price_tv?.setTextColor(itemView.resources.getColor(R.color.green_6AB578))
            }
//            price_tv?.text = bean.assetPrice.toString()
//            num_tv?.text = bean.totalAmt.toString()
        }
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        val viewHolder = holder as VH
        viewHolder.bindData(dataList()[position])
    }
}